package com.ruoyi.project.beautyflower.stagingMonths.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.beautyflower.stagingMonths.domain.StagingMonths;
import com.ruoyi.project.beautyflower.stagingMonths.service.IStagingMonthsService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 分期月数设置 信息操作处理
 * 
 * @author lxs
 * @date 2018-10-09
 */
@Controller
@RequestMapping("/beautyflower/stagingMonths")
public class StagingMonthsController extends BaseController
{
    private String prefix = "beautyflower/stagingMonths";
	
	@Autowired
	private IStagingMonthsService stagingMonthsService;
	
	@RequiresPermissions("beautyflower:stagingMonths:view")
	@GetMapping()
	public String stagingMonths()
	{
	    return prefix + "/stagingMonths";
	}
	
	/**
	 * 查询分期月数设置列表
	 */
	@RequiresPermissions("beautyflower:stagingMonths:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(StagingMonths stagingMonths)
	{
		startPage();
        List<StagingMonths> list = stagingMonthsService.selectStagingMonthsList(stagingMonths);
		return getDataTable(list);
	}
	
	/**
	 * 新增分期月数设置
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存分期月数设置
	 */
	@RequiresPermissions("beautyflower:stagingMonths:add")
	@Log(title = "分期月数设置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(StagingMonths stagingMonths)
	{		
		return toAjax(stagingMonthsService.insertStagingMonths(stagingMonths));
	}

	/**
	 * 修改分期月数设置
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		StagingMonths stagingMonths = stagingMonthsService.selectStagingMonthsById(id);
		mmap.put("stagingMonths", stagingMonths);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存分期月数设置
	 */
	@RequiresPermissions("beautyflower:stagingMonths:edit")
	@Log(title = "分期月数设置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(StagingMonths stagingMonths)
	{		
		return toAjax(stagingMonthsService.updateStagingMonths(stagingMonths));
	}
	
	/**
	 * 删除分期月数设置
	 */
	@RequiresPermissions("beautyflower:stagingMonths:remove")
	@Log(title = "分期月数设置", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(stagingMonthsService.deleteStagingMonthsByIds(ids));
	}
	
}
